package com.xin.data.simbapesa.adapter;

import android.annotation.SuppressLint;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.ViewGroup;


import com.xin.data.simbapesa.R;
import com.xin.data.simbapesa.base.BaseBindingAdapter1;
import com.xin.data.simbapesa.databinding.SimbaDesItemBinding;
import com.xin.data.simbapesa.obj.PermissionDesInfo;
import com.xin.data.simbapesa.utils.NumUtils;
import com.xin.data.simbapesa.utils.ResUtils;

import java.util.List;

public class PermissionDesAdapter extends BaseBindingAdapter1<PermissionDesInfo, SimbaDesItemBinding> {


    private static final int TYPE_A = 1;

    public PermissionDesAdapter(List<PermissionDesInfo> dataList) {
        super(dataList);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void bindData(SimbaDesItemBinding binding, PermissionDesInfo item, int position) {

        binding.tvIcon.setImageResource(item.getIcon());
        binding.tvTitle.setText(item.getName());

        binding.tvAmount.setText(Html.fromHtml(ResUtils.s(R.string.permission_des_item_title2, String.valueOf(item.getAmount()))));

        String rateStr = NumUtils.formatToTwoDecimals(item.getRate() * 100);
        binding.tvRate.setText(Html.fromHtml(ResUtils.s(R.string.permission_des_item_title3, rateStr + "%")));

        binding.tvSubTitle.setText(item.getContent());


    }

    @Override
    protected int getItemType(PermissionDesInfo item) {

        return TYPE_A;

    }

    @Override
    protected SimbaDesItemBinding createBinding(LayoutInflater inflater, ViewGroup parent, int viewType) {
        return SimbaDesItemBinding.inflate(inflater, parent, false);
    }


}
